public class Spring {
  // a reference to the engine
  private ParticleEngine engine;
  
  //the two particles the spring is connected too
  public Particle start;
  public Particle end;
  protected boolean appear;
  protected String l1, l2;
  
  //spring length and constant
  public float springLength;
  public float springConstant;
   // flag to indicate whether or not the spring is destroyed
  public boolean destroyed;
  
  public Spring(Particle start, Particle end, float springLength, float springConstant) {
    this.start = start;
    this.end = end;
    this.springLength = springLength;
    this.springConstant = springConstant;
    this.appear = false;
  }
  
  public Spring(String l1, String l2, float springLength, float springConstant) {
    this.l1 = l1;
    this.l2 = l2;
    this.springLength = springLength;
    this.springConstant = springConstant;
    this.appear = false;
  }
  
  public void setEngine(ParticleEngine engine) {
    this.engine = engine;
  }
  
  public void update() {
    if(start.clicked){
      appear = true;
      end.linked=true;
      println("Le: "+ end.label);
    }else{
    if(end.clicked){
        appear = true;
        start.linked=true;
        println("Ls: "+ start.label);
    }
    else{
      appear = false;
      start.linked = false;
      end.linked=false;
    }
   }
  }
  
  public void draw() {
    noFill();
    if(this.appear)  stroke(255);
    else noStroke();
    strokeWeight(2);
    line(start.x, start.y, end.x, end.y);
  }
  
}
